package com.example.fengyungo.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 普通工具类
 */
public class CommonUtils {

    /**
     * 根据当前时间生成id："yyyyMMddHHmmss"
     * @return 生成的id
     */
    public static String initIdByNowTime() {
        DateTimeFormatter formatterForId = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        LocalDateTime now = LocalDateTime.now();
        String id = now.format(formatterForId);
        return id;
    }

    /**
     * 获取当前时间
     * @return 生成的日期时间
     */
    public static String getNowTime() {
        DateTimeFormatter formatterForCreateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();
        String dateTime = now.format(formatterForCreateTime);
        return dateTime;
    }
}
